package com.itheima.exer.homework.hw1008;

import java.util.Map;
import java.util.TreeMap;

/**
 * dhasjhdjahsjkdahjkdhajkhcjkhjkahsjkdahdkwqhuwyeuiqey
 *
 * 统计任意一个英文字符串中单词出现的次数,统计一个英文字符串中字母出现的次数.
 */
public class Count2Test {
    private static final Map<Character,Integer> MAP = new TreeMap<>();
    public static void main(String[] args) {
        String str = "dhasjhdjahsjkdahjkdhajkhcjkhjkahsjkdahdkwqhuwyeuiqey";
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (MAP.containsKey(c)){
                MAP.put(c,MAP.get(c)+1);
            }else {
                MAP.put(c,1);
            }
        }
        for (Map.Entry<Character, Integer> entry : MAP.entrySet()) {
            System.out.println(entry.getKey() + "出现了"+ entry.getValue()+"次");
        }
    }
}
